/**
 * Copyright (C), 2020, 安徽贝慕信息科技有限公司
 * FileName: UserLoginController
 * Author:   Allen
 * Date:     2020/8/27 20:07
 * Description: 用户登录
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.bim.marvel.rest;

import com.bim.marvel.auth.client.resource.model.dto.TokenDTO;
import com.bim.marvel.openapi.client.query.LoginQuery;
import com.bim.marvel.common.core.constant.MediaTypeExtend;
import com.bim.marvel.common.core.model.dto.SimpleVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 〈用户登录接口〉
 *
 * @author Allen
 * @date 2020/8/27
 * @since 1.0.0
 */
@Api(tags = {"用户登录-controller"})
public interface DealerUserLoginController {

    /**
     * 用户登录
     */
    String USER_LOGIN = "/api/user/login";

    /**
     * 刷新用户Token
     */
    String USER_REFRESH_TOKEN = "/api/user/refresh/token";

    /**
     * 用户登录
     *
     * @param loginQuery 用户登录入参信息
     * @return 返回结果
     */
    @ApiOperation(value = "用户登录", notes = "用户登录",
            protocols = "http,https", httpMethod = "POST")
    @PostMapping(value = USER_LOGIN, consumes = {MediaTypeExtend.APPLICATION_FORM_URLENCODED_UTF8_VALUE},
            produces = {MediaType.APPLICATION_JSON_VALUE})
    SimpleVO<TokenDTO> userLogin(@Validated LoginQuery loginQuery);

    /**
     * 刷新用户Token
     *
     * @param refreshToken 请求的Token
     * @return 返回结果
     */
    @ApiOperation(value = "刷新用户Token", notes = "刷新用户Token",
            protocols = "http,https", httpMethod = "POST")
    @PostMapping(value = USER_REFRESH_TOKEN, consumes = {MediaTypeExtend.APPLICATION_FORM_URLENCODED_UTF8_VALUE},
            produces = {MediaType.APPLICATION_JSON_VALUE})
    SimpleVO<TokenDTO> refreshToken(@ApiParam(name = "refreshToken", value = "请求的Token", required = true,
            example = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsibWFydmVsLWF1dGgtc2VydmVyIiwibWFydmVsLW1pZGRsZ"
                    + "S1zZXJ2ZXIiXSwidXNlcl9uYW1lIjoic3VwZXJhZG1pbiIsInNjb3BlIjpbInJlYWQiLCJ3cml0ZSJdLCJhdGkiOiI3ZDk5"
                    + "YjRlOS04ZWIwLTQ5OGYtYmFkYi1kZjgzZTZjNDZkMjYiLCJleHAiOjE2MDEwMjM1MTMsImp0aSI6IjhiOGUyYWRhLWM1ODA"
                    + "tNDM3YS05MmYxLTFkZjhmOTM3ZDJhMyIsImNsaWVudF9pZCI6Im1pZGRsZSJ9.Nmw-TnL6lC3aImZ-DlUBqPIGV2YCBJu3tP6t2rIFfUg")
                                    @RequestParam(value = "refreshToken") String refreshToken);
}
